package com.distribution.system.controller;

import com.distribution.common.annotation.RepeatSubmit;
import com.distribution.common.core.controller.BaseController;
import com.distribution.common.core.domain.AjaxResult;
import com.distribution.common.core.domain.entity.SysUser;
import com.distribution.common.core.page.TableDataInfo;
import com.distribution.system.domain.dto.CmccDaReportedDTO;
import com.distribution.system.domain.entity.CmccDaReported;
import com.distribution.system.mapper.SysUserMapper;
import com.distribution.system.service.CmccDaReportedService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Liping Huo
 * @date 2023/5/23 15:53
 */
@RestController
@RequestMapping(value = "/cmccDaReported")
@Slf4j
public class CmccDaReportedController extends BaseController {

    @Resource
    SysUserMapper sysUserMapper;
    @Resource
    CmccDaReportedService cmccDaReportedService;

    @PostMapping("/listCmccDaReported")
    TableDataInfo listCmccDaReported(@RequestBody CmccDaReportedDTO cmccDaReportedDTO) {
        Long userId = getUserId();
        SysUser sysUser = sysUserMapper.selectUserById(userId);
        List<CmccDaReported> CmccDaReportedList = cmccDaReportedService.listCmccDaReported(cmccDaReportedDTO,sysUser);
        return getDataTable(CmccDaReportedList);
    }

    @RequestMapping(value = "/addReported",method = RequestMethod.POST)
    @RepeatSubmit()
    public AjaxResult addAgent(@RequestBody CmccDaReported cmccDaReported) {
        cmccDaReportedService.addReported(cmccDaReported);
        return success();
    }

    /*修改上报状态*/
    @RequestMapping(value = "/updateReported")
    public AjaxResult updateReported(@RequestBody CmccDaReported cmccDaReported) {
        cmccDaReportedService.updateReported(cmccDaReported);
        return success();
    }

}
